from django.db.models import CharField,DateTimeField,BooleanField,TextField,IntegerField,ForeignKey,DO_NOTHING,PROTECT
from apps.vadmin.op_drf.models import CoreModel


class Models(CoreModel):
    name = CharField(max_length=256,null=False,verbose_name="型号名称")
    deleted_datetime = DateTimeField(null=True,verbose_name="删除时间")
    model_number = CharField(max_length=128,null=False,verbose_name="型号编码")
    manufacturer = ForeignKey(to="assets.Manufacturers",null=True,db_constraint=False,on_delete=PROTECT,verbose_name="删除时间")
    depreciation = ForeignKey(to="assets.Depreciations",null=True,db_constraint=False,on_delete=PROTECT,verbose_name="折旧表id")
    category = ForeignKey(to="assets.Categories",null=True,db_constraint=False,on_delete=PROTECT,verbose_name="分类ID")
    eol = IntegerField(null=True,verbose_name="寿命，多少个月")
    image = CharField(null=True,max_length=256,verbose_name="图片地址")
    deprecated_mac_address = BooleanField(null=False,default=0,verbose_name="MAC地址是否弃用")
    notes = TextField(null=True,verbose_name="备注")
    requestable = BooleanField(null=False,default=0,verbose_name="是否可申请")


    class Meta:
        verbose_name = '资产型号'
        verbose_name_plural = verbose_name

    def __str__(self):
        return f"{self.name}"
